local fengong = fk.CreateSkill {
  name = "kl__fengong",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["kl__fengong"] = "焚弓",
  [":kl__fengong"] = "锁定技，你的攻击范围+1，你的伤害牌始终无视防具，你的属性【杀】均视为【万箭齐发】。"..
  "当你对一名“鬼”角色造成1点伤害时，若其在你的攻击范围内，你获得其一张牌并与其各摸一张牌。",

  ["$kl__fengong1"] = "脚踏风雨，手握雷霆，曳断九天银河！",
}

fengong:addEffect("atkrange", {
  correct_func = function(self, from, to)
    if from:hasSkill(fengong.name) then
      return 1
    end
  end,
})

fengong:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fengong.name) and data.card and data.card.is_damage_card and table.find(data.tos, function (p)
      return p:getEquipment(Card.SubtypeArmor) ~= nil
    end)
  end,
  on_use = function(self, event, target, player, data)
    local use_event = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
    if use_event == nil then return end
    for _,p in ipairs(player.room.players) do
      player.room:addPlayerMark(p, MarkEnum.MarkArmorNullified, 1)
    end
    use_event:addCleaner(function()
      for _,p in ipairs(player.room.players) do
        player.room:removePlayerMark(p, MarkEnum.MarkArmorNullified)
      end
    end)
  end,
})

fengong:addEffect("filter", {
  card_filter = function(self, to_select, player)
    return player:hasSkill(fengong.name) and to_select.trueName == "slash" and to_select.name ~= "slash" and
    table.contains(player:getCardIds("h"), to_select.id)
  end,
  view_as = function(self, player, to_select)
    local card = Fk:cloneCard("archery_attack", to_select.suit, to_select.number)
    card.skillName = fengong.name
    return card
  end,
})

fengong:addEffect(fk.DamageCaused, {
  anim_type = "control",
  trigger_times = function (self, event, target, player, data)
    return data.damage
  end,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fengong.name) and player:inMyAttackRange(data.to) and
    data.to:getMark("@@klmo__huangzhong_gui") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if not data.to:isNude() then
      local card = room:askToChooseCard(player, {
        target = data.to,
        flag = "he",
        skill_name = fengong.name,
      })
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, fengong.name, nil, false, player)
    end
    if not player.dead then
      player:drawCards(1, fengong.name)
      if not data.to.dead then
        data.to:drawCards(1, fengong.name)
      end
    end
  end,
})


return fengong
